<template>
  <super-table
    :key="superTableKey"
    :column="column"
    v-model="tableData"
    :selectionRowCache="selectionRowCache"
    @hook:destroyed="destoryedComponentHandler"
    v-bind="$attrs"
  >
    <template #action="{scope}">
      <slot
        v-bind:scope="{
          row: scope.row,
          column: scope.column,
          index: scope.index,
        }"
        name="action"
      >
      </slot>
    </template>
  </super-table>
</template>

<script>
import { ref, toRefs } from "vue";
import superTable from "./components/super-table.vue";
export default {
  components: { superTable },
  name: "SuperTableIndex",
  props: {
    column: {
      type: Array,
      required: true,
    },
    tableData:{
      type: Array,
      required: true,
    }
  },
  setup(props, context) {
    let { column,tableData } = toRefs(props);
    let superTableKey = ref(1),
      selectionRowCache = ref(new Map());
    let resizeHandler = function () {
      if (superTableKey.value >= 9999) superTableKey.value = 1;
      else superTableKey.value++;
    };
    window.addEventListener("resize", resizeHandler, false);
    let destoryedComponentHandler = function () {
      console.log("supertable组件销毁");
      window.removeEventListener("resize", resizeHandler, false);
    };

    return {
      destoryedComponentHandler,
      selectionRowCache,
      superTableKey,
      column,
      tableData
    };
  },
};
</script>

<style>
</style>